package com.summer.core.web.action.admin;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.ParentPackage;

import com.summer.core.action.BaseAction;
import com.summer.core.bean.Pager;
import com.summer.core.entity.Field;
import com.summer.core.service.FieldService;

@ParentPackage("admin")
public class FieldAction extends BaseAction<Field, FieldService> {
	
	private List<Field> fields;
	
	public List<Field> getFields() {
		return fields;
	}

	public void setFields(List<Field> fields) {
		this.fields = fields;
	}

	public Field getField() {
		return getBean();
	}

	public void setField(Field sTable) {
		setBean(sTable);
	}
	
	public String execute()
	{
		return "";
	}

	/**
	 * 全部更新
	 * @return
	 */
	public String edit_all()
	{
		dlist=service.getList("table.id",bean.getTable().getId());
		
		return result("input_all");
		
	}
	
	
	public String update_all()
	{
		String tableid="";
		if(fields !=null)
		{
		for(int i=0;i<fields.size();i++)
		{
			service.update(fields.get(i));
		}
		redirectionUrl="field!list.action?field.table.id="+fields.get(0).getTable().getId();
		}
		return SUCCESS;
	}
	
	public String list()
	{
		if(pager==null)
		{pager=new Pager();
		pager.setKeyword(bean.getTable().getId());
		pager.setProperty("table.id");
		}
		pager = service.findByPager(pager);
	
		return result(LIST);
	}
	
	@Resource
	public void setService(FieldService service) {
		super.setService(service);
	}

}
